import numpy as np
# Linear Regression Using Normal Equation
def linear_regression_normal_equation(X: list[list[float]], y: list[float]) -> list[float]:
	# Your code here, make sure to round
    X = np.array(X)
    y = np.array(y).reshape(-1, 1)
    # 使用正规方程计算 theta
    # theta = (X^T * X) * X^T * y
    theta = np.linalg.inv(X.T @ X) @ X.T @ y
    theta = np.round(theta, 4).flatten().tolist()
    return theta
# 示例数据
X = [[1, 3, 4], [1, 2, 5], [1, 3, 2]]
y = [1, 2, 1]

# 计算回归系数
theta = linear_regression_normal_equation(X, y)
print(theta)  # 输出: [4.0, -1.0, -0.0]